import Vue from "vue";
import Vuex from "vuex"

//一定要在创建仓库之前将vuex注册为vue的插件
Vue.use(Vuex)

//创建仓库  仓库中的state配置会转绑给store对象
const store = new Vuex.Store({
    strict: true,
    state:{
        firstName:"T",
        lastName:"Mac",
        msg:"❤"
    },
    getters:{
        fullName(state){
            return state.firstName +"-"+ state.lastName
        }
    },
    mutations:{
        add(state,star){
            state.msg+=star
        }
    },
    actions:{
        add(store,star){
            store.commit("add",star)
        }
    }
})

export default store